<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>下载历史 - 学习资源平台</title>
    <link rel="stylesheet" th:href="@{/css/common.css}">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link rel="stylesheet" th:href="@{/css/history.css}">
</head>
<body>
<div class="container mt-4">
    <div class="back-btn">
        <a th:href="@{/user/digital}" class="btn btn-secondary">
            <i class="fas fa-arrow-left me-1"></i>返回个人中心
        </a>
    </div>

    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a th:href="@{/user/digital}">个人中心</a></li>
            <li class="breadcrumb-item active">下载历史</li>
        </ol>
    </nav>

    <div class="card">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">下载历史</h5>
            <span class="badge bg-primary" th:text="${downloadHistoryList != null ? downloadHistoryList.size() : 0}">0</span>
        </div>
        <div class="card-body">
            <div th:if="${downloadHistoryList == null or downloadHistoryList.isEmpty()}" class="empty-history">
                <i class="fas fa-download"></i>
                <h5>暂无下载记录</h5>
                <p class="text-muted">您还没有下载过任何学习资源</p>
                <a th:href="@{/resource/list}" class="btn btn-primary">去下载资源</a>
            </div>

            <div th:if="${downloadHistoryList != null and !downloadHistoryList.isEmpty()}">
                <div th:each="history : ${downloadHistoryList}" class="resource-item">
                    <h5 class="resource-title">
                        <a th:href="@{'/resource/' + ${history.resourceId}}" th:text="${history.resourceTitle}">资源标题</a>
                    </h5>
                    <div class="resource-meta">
                        <span th:text="${history.majorName}">专业名称</span>
                        <span class="mx-2">|</span>
                        <span th:text="${history.resourceType}">文档</span>
                        <span class="mx-2">|</span>
                        <span th:text="${history.resourceType}">必修</span>
                    </div>
                    <p class="resource-description" th:text="${history.resourceDescription ?: '暂无描述'}">
                        资源描述
                    </p>
                    <div class="d-flex justify-content-between align-items-center">
                        <div class="download-time">
                            <i class="fas fa-clock me-1"></i>
                            下载时间: <span th:text="${#temporals.format(history.uploadTime, 'yyyy-MM-dd HH:mm')}">下载时间</span>
                        </div>
                        <div>
                            <a th:href="@{'/resource/' + ${history.resourceId}}" class="btn btn-sm btn-outline-primary">
                                <i class="fas fa-eye me-1"></i>查看详情
                            </a>
                            <a th:href="@{'/resource/download/' + ${history.resourceId}}" class="btn btn-sm btn-outline-success">
                                <i class="fas fa-download me-1"></i>重新下载
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 页脚 -->
<div class="footer mt-5">
    <div class="container">
        <p>&copy; 2025 学习资源平台. 保留所有权利.</p>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>